package com.niit.common;

/**
 * 表示返回的统一格式的结果集
 * 
 * @author Administrator
 *
 */
public class Result {
	// 1表示成功，0表示失败
	private int code;
	// 返回给前端的信息
	private String message;
	// 返回给前端的数据
	private Object data;

	public static Result success(String message) {
		Result r = new Result();
		r.setCode(1);
		r.setMessage(message);
		r.setData(null);
		return r;
	}

	public static Result success(String message, Object data) {
		Result r = success(message);
		r.setData(data);
		return r;
	}
	
	public static Result error(String message) {
		Result r = new Result();
		r.setCode(0);
		r.setMessage(message);
		r.setData(null);
		return r;
    }

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

}
